<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      console.log("同步代码", 1); //同步代码
      setTimeout(() => {
        console.log("宏任务代码", 2);
      }, 1000);
      Promise.resolve().then(() => {
        console.log("微任务代码", 3);
      });
      new Promise((resolve) => {
        console.log("同步代码", 4); //同步代码
        resolve(); //同步代码
      }).finally(() => {
        console.log("微任务代码", 5);
      });
      console.log("同步代码", 6); //同步代码
    </script>
  </body>
</html>
